const {resolve} = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')


module.exports = {
    // entry:"./src/js/index.js",
    //多入口
    entry:{
        index:"./src/js/index.js",
        pre:"./src/js/pre.js"
    },
    output:{
        // [name] 入口文件名
        filename:"js/[name].[contenthash:10].js",
        path:resolve(__dirname,"build")
    },
    plugins:[ 
        //编译html
        new HtmlWebpackPlugin({
            filename:"index.html",
            template:"./src/index.html",
            minify:{
                collapseWhitespace:true,
                removeComments:true
            }
        })

    ],
    mode:"production", 
    // optimization:{
    //     //对于动态导入模块，默认使用 webpack v4+ 提供的全新的通用分块策略，及时多个文件
    //     splitChunks:{
    //          // include all types of chunks
    //         chunks:"all"
    //     }
    // }
}